<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			var arr = [];
			var index = 0;
			var flag = true;

			//构建函数
			function Student(no, name) {
				this.no = no;
				this.name = name;
			}

			function addStu() {
				var stuNo = prompt("请输入学号");
				var stuName = prompt("请输入姓名");
				var stu = new Student(stuNo, stuName);
				arr[index] = stu;
				index++;
			}

			function delStu() {
				var delNo = prompt("请输入要删除的学生学号");
				for (var k = 0; k < arr.length; k++) {
					if (arr[k].no == delNo) {
						arr[k] = null;
						break;
					}
				}
			}

			function listStu() {
				for (var i = 0; i < arr.length; i++) {
					if (arr[i] != null) {
						alert(arr[i].no + "," + arr[i].name);
					}
				}
			}

			function updateStu() {
				var updateNo = prompt("请输入要修改的学生学号");
				var updateName = prompt("请输入要修改的学生姓名");
				for (var j = 0; j < arr.length; j++) {
					if (arr[j].no == updateNo) {
						arr[j].name = updateName;
						break;
					}
				}
			}

			function login() {
				do {
					var name = prompt("请输入用户名");
					var password = prompt("请输入密码");
					if (name === "tom" && password === "123") {
						break;
					}
				} while (true);
			}
			var a = prompt("1.登录2.退出");
			switch (a) {
				case "1":
					login();
					do {
						var b = prompt("1.添加2.删除3.遍历4.修改5.退出");
						switch (b) {
							case "1":
								addStu();
								break;
							case "2":
								delStu();
								break;
							case "3":
								listStu();
								break;
							case "4":
								updateStu();
								break;
							case "5":
								flag = false;
								break;
						}
					} while (flag);
					break;
				case "2":
					break;
			}
			alert("欢迎下次再用");
		</script>
	</head>
	<body>
	</body>
</html>
